import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import { AtToast } from "taro-ui"

import './advlist.scss'
class AdvList extends Component {
	constructor() {
		super(...arguments)
		this.state = {
			isShowToast: false,
		}
	}
	toPageSubscribe() {
		Taro.navigateTo({ url: "/pages/subscribe/index" })
	}
	toPageGetVip() {
		Taro.navigateTo({ url: "/pages/getvip/index" })
	}
	isShowToastBtn() {
		this.setState({
			isShowToast: true,
		}, () => {
			setTimeout(() => {
				this.setState({
					isShowToast: false
				})
			}, 1500)
		})
	}
	render() {
		return (
			<View className='adv-list'>
				<View className="adv-item" onClick={this.toPageGetVip}>
					<Image className="img" src={require('../../../asset/imgs/adv1.png')} />
					<View className="txt">领取VIP</View>
				</View>
				<View className="adv-item" onClick={this.toPageSubscribe}>
					<Image className="img" src={require('../../../asset/imgs/adv2.png')} />
					<View className="txt">预约</View>
				</View>
				<View className="adv-item" onClick={this.isShowToastBtn.bind(this)}>
					<Image className="img" src={require('../../../asset/imgs/adv3.png')} />
					<View className="txt">活动</View>
				</View>
				<View className="adv-item margin" onClick={this.isShowToastBtn.bind(this)}>
					<Image className="img" src={require('../../../asset/imgs/adv4.png')} />
					<View className="txt">学装修</View>
				</View>
				<AtToast
					isOpened={this.state.isShowToast}
					text="该功能暂未开通！"
					duration={2000}
				></AtToast>
			</View >
		)
	}
}

export default AdvList
